package com.itheima.springbootrequestresponse.dao.impl;

import com.itheima.springbootrequestresponse.dao.UserDao;
import com.itheima.springbootrequestresponse.pojo.User;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * UserDaoImpl
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/7/7 20:03
 */
@Repository
public class UserDaoImpl implements UserDao {

    private static final List<User> USERS = new ArrayList<>();

    @Override
    public User getByUserName(String username) {
        Optional<User> userOptional = USERS.stream()
                .filter(item -> item.getName().equals(username))
                .findAny();
        return userOptional.orElse(null);
    }
}
